<template>
  <el-container>
    <el-aside width="200px" height="100vh">
      <el-menu :default-active="$route.path" router>
        <el-submenu v-for="(item, index) in menu.items"
          :index="`menu-itme-${index}`"
          :key="item.index">
          <template slot="title">
            {{ item.title }}
          </template>
          <el-menu-item v-for="(subItem, subIndex) in item.items"
            :index="subItem.path" :key="`menu-item-${index}-${subIndex}`">
              {{ subItem.title }}
          </el-menu-item>
        </el-submenu>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header>
       <h3> xinli-后台管理界面</h3>
      </el-header>
      <el-main>
        <router-view :key="$route.path"></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script lang="ts">
import { Vue, Component } from 'vue-property-decorator'

@Component({})
export default class Main extends Vue {
  menu = {
    items: [
      {
        title: '内容管理',
        items: [
          { title: '首页', path: '/' },
          { title: '人物管理', path: '/personages/list' },
          { title: '作品管理', path: '/works/list' },
          { title: '横幅管理', path: '/banners/list' },
          { title: '壁纸管理', path: '/wallpapers/list' }
        ]
      },
      {
        title: '运营管理',
        items: [
          { title: '用户管理', path: '/users/list' }
        ]
      }
    ]
  }
}
</script>

<style>
body{
  margin: 0;
}
</style>
